package com.estrend.redbird
import android.os.Bundle
import android.widget.Toast
import com.estrend.redbird.base.BaseRedBirdActivity
import com.estrend.redbird.databinding.ActivityMainBinding
import com.king.frame.mvvmframe.di.module.HttpModule
import com.orhanobut.logger.Logger
import dagger.hilt.android.AndroidEntryPoint

const val TAG = "MainActivity"
@AndroidEntryPoint
class MainActivity: BaseRedBirdActivity<MainViewModel, ActivityMainBinding>() {

    private var backPressedTime: Long = 0
    private lateinit var toast: Toast
    override fun reFreshOnline() {

    }

    override fun getLayoutId(): Int {
       return R.layout.activity_main
    }

    override fun initData(savedInstanceState: Bundle?) {
      Logger.d(TAG,"initData")
    }

    override fun onBackPressed() {
        val currentTime = System.currentTimeMillis()
        if (currentTime - backPressedTime < 2000) {
            toast.cancel()
            super.onBackPressed()
            return
        } else {
            toast = Toast.makeText(this, "Press back again to exit", Toast.LENGTH_SHORT)
            toast.show()
        }
        backPressedTime = currentTime
    }

}

